#include<stdio.h>
#include<string.h>

/*
       变量：
        局部变量
        全局变量 这个程序都可以访问
*/
int g_data = 100;

int main()
{
    #if 0
    /*{}作用域：局部变量就是定义在{}内部。离开作用域就访问不到*/
    {
    /*任何变量都有一个地址*/
    int money = 0;

    /*&:取地址符*/
    scanf("%d",&money);

    printf("&money:%p\n",&money);

    printf("money:%d\n",money);

    printf("g_data:%d\n",g_data);
     }

       printf("g_data:%d\n",g_data);
       #endif

#if 0
    int num = 100;

    num = 300;

    printf("num = %d\n",num);
    
    /*指针：指向某一个地址*/
    int * ptr =&num;
    printf("*p = %d\n",*ptr);

    *ptr  = 666;
    printf("num = %d\n",num);
    printf("*p = %d\n",*ptr);

    int **pptr =  &ptr;

    
#endif

#if 0
     int num1 = 100, num2 = 200;

     int *pnum1 = &num1;
     int *pnum2 = &num2;

     int temp = *pnum1;
     *pnum1 = *pnum2;
     *pnum2 = temp;

     printf("num1:%d\n",num1);
     printf("num2:%d\n",num2);
#endif

#if 1
      int num = 100;
      int *pnum = &num;
      printf("*pnum = %d\n",*pnum);
      int length = sizeof(pnum);
      printf("length = %d\n",length);


      char ch = 'A';
      char *ptr = &ch;
      printf("*ptr = %c\n",*ptr);
      length = sizeof(ptr);
      printf("length = %d\n",length);
      /*指针占用的字节永远是8字节*/
    
#endif
  
}